package com.lee.boot.head.first.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;


/**
 * @Description: 重定向
 * @Param:
 * @Return :
 * @author: Lee
 * @Date: 2019/11/23
 */
@Controller
@RequestMapping(value = "/redirect")
public class RedirectController {


    @RequestMapping(value = "/simple")
    public String redirect1() {
        return "redirect:/user/list";
    }

    @RequestMapping(value = "model")
    public ModelAndView redirect2(ModelAndView modelAndView) {
        modelAndView.setViewName("redirect:/user/list");
        return modelAndView;
    }

    @RequestMapping(value = "object")
    public ModelAndView redirect3(RedirectAttributes redirectAttributes, ModelAndView modelAndView) {
        redirectAttributes.addFlashAttribute("id", "111");
        modelAndView.setViewName("redirect:/user/list");
        return modelAndView;
    }





}
